Skip to content

Conversation

joadoumie
Copy link
Contributor

@joadoumie joadoumie commented Oct 5, 2025

WIP Draft - Exploration

This is definitely a work in progress and based off of some of the really cool incoming changes with #1479.

My goal was to move away from an attachment flow where the entire context of a file is injected into the prompt and rely on some of the tools that are being introduced in #1479.

Description

This PR builds on top of the tool calling implementation to improve the attachments workflow by not including the full file context but rather relying on the agentic capabilities of Jupyternaut

Relates to discussions in the original file attachment PR -- #1419

Code changes

1. Fix tool call UI display bug (c1468ff)

  • Renamed id to tool_id across the tool call components -- I don't know that this was necessary but I could not get the UI to work properly otherwise.
  • It seems that the id attribute is a reserved HTML attribute that doesn't properly pass through web components to React props? Not sure this is true either, but again this worked for me for testing this flow.
  • Updated 4 files: toolcall_list.py, types.py, web-components-plugin.ts, and jai-tool-call.tsx

2. Add workspace directory context to file tools (f51c847 + 9211dd3)

  • Added optional cwd parameter to read(), edit(), and write() tools in default_toolkit.py
  • Tools now resolve relative file paths against the workspace directory
  • Modified JupyternautPersona._build_toolkit() to create a context-aware toolkit using functools.partial
  • Created bind_cwd() helper function that preserves __name__ and __doc__ attributes for LiteLLM compatibility
  • All file operations now automatically work with files referenced in attachments without requiring absolute paths

User-facing changes

Improved file handling with attachments

  • When users attach files like example.txt, the assistant can now successfully read/edit/write them using just the filename
  • Previously, the entire context of the file was injected in, which isn't ideal.
  • The workspace directory is automatically determined from the chat context and bound to all file tools

Backwards-incompatible changes

None. The cwd parameter is optional and defaults to None, maintaining backwards compatibility with existing code that passes absolute paths.

dlqqq and others added 16 commits September 15, 2025 10:10
This commit adds workspace directory awareness to tools (bash and search_grep)
by creating a dynamic toolkit that binds the workspace directory to tool calls.
Also updates the system prompt to guide the LLM on when to use these tools.

Note: This version has a bug where tool call UI is not displaying properly.
Saving this commit to preserve the directional changes before reverting.
The id attribute is a reserved HTML attribute and was not being properly
passed to the React component when used in web components. This caused
the tool call UI to not display because the component returned null when
props.id was undefined.

Changed all instances of id to tool_id in:
- toolcall_list.py: Changed prop key from "id" to "tool_id"
- types.py: Updated JaiToolCallProps type definition
- web-components-plugin.ts: Updated prop declaration and allowed attributes
- jai-tool-call.tsx: Updated TypeScript interface and usage
Added cwd parameter to read, edit, and write tools to support relative
file paths. The tools now resolve relative paths against the workspace
directory, allowing the LLM to reference files without absolute paths.

Changes:
- Added cwd parameter to read(), edit(), and write() in default_toolkit.py
- Updated _build_toolkit() to use functools.partial with a helper function
- Replaced verbose wrapper functions with cleaner partial binding approach
- All file tools now receive workspace directory context automatically
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants